#pragma once

#include "Entity.h"
#include "../SGD Wrappers/SGD_Listener.h"
#include "ShadowHook.h"
#include "Planets.h"

class IGameState;

class Player : public Entity, public SGD::Listener
{
public:
	Player();
	virtual ~Player();

	//interface
	virtual void Update(float elapsedTime) override;
	virtual void Render() override;
	virtual int GetType() const override { return ENT_PLAYER; }
	virtual void HandleCollision(const IEntity* other) override;

	//Listener interface
	virtual void HandleEvent(const SGD::Event* event) override;

	//accessors
	float GetHealth() const { return health; }
	Planets * GetCurrentPlanet() const { return CurrentPlanet; }
	Planets * GetDestinationPlanet() const { return DestinationPlanet; }
	Entity * GetGrappledObject() const {return GrappledObject;}
	bool GetGrappleActive() const { return grappleactive; }
	float GetCorruption()const{ return corruption; }
	bool GetLose() const{ return Lose; }
	bool GetWin() const{ return Win; }
	float GetLoseTimer() const{ return losetimer; }
	float GetOrbitSpeed() const { return orbitspeed; }
	bool GetControllerGrapple() const { return controllerGrapple; }
	SGD::Vector GetControllerVector() const { return controllerVector; }
	IGameState* GetCurrentState() const { return currState; }
	int GetZoneCounter() const { return zoneCounter; }

	int Getlightorbscollected() const { return lightOrbsCollected; }
	int  Getenemieskilled() const { return enemiesKilled; }
	int  Getgrapplesfired() const { return grapplesFired; }
	bool  Getlightorbacheivement() const { return lightOrbAcheivement; }
	bool  Getenemyacheivement() const { return enemyAcheivement; }
	bool  Getgrappleacheivement() const { return grappleAcheivement; }

	//mutators
	void SetCurrentPlanet(Planets * inplanet) { CurrentPlanet = inplanet; }
	void SetDestinationPlanet(Planets * inplanet) { DestinationPlanet = inplanet; }
	void SetGrappleActive(bool inbool){ grappleactive = inbool; }
	void SetHealth(float h) { health = h; }
	void SetCorruption(float h) { corruption = h; }
	void SetOrbitSpeed(float innum) { orbitspeed = innum; }
	void SetGrappledObject(Entity * inobject) { GrappledObject = inobject; }
	void SetControllerGrapple(bool b) { controllerGrapple = b; }
	void SetJumpTimer(float f){ jumptimer = f; }
	float grappledistance = 0;
	void SetCurrentState(IGameState* s){ currState = s; }
	void SetZoneCounter(int zC){ zoneCounter = zC; }

	void Setlightorbscollected(int innum) { lightOrbsCollected = innum; }
	void Setenemieskilled(int innum) { enemiesKilled = innum; }
	void Setgrapplesfired(int innum) { grapplesFired = innum; }
	void Setlightorbacheivement(bool inbool) { lightOrbAcheivement = inbool; }
	void Setenemyacheivement(bool inbool)  { enemyAcheivement = inbool; }
	void Setgrappleacheivement(bool inbool) { grappleAcheivement = inbool; }

private:
	float health = 100;
	float corruption = 0;
	float debugFire = 0.0f;
	Planets * CurrentPlanet = nullptr;
	Planets * DestinationPlanet = nullptr;
	bool grappleactive = false;
	float jumptimer = 0;
	bool Lose = false;
	bool Win = false;
	float losetimer = 2;
	float orbitspeed = 0;
	float pullspeed = 0;
	Entity * GrappledObject = nullptr;
	bool controllerGrapple = false;

	SGD::Vector controllerVector;

	SGD::HTexture healthBar = SGD::INVALID_HANDLE;
	SGD::HTexture corruptionBar = SGD::INVALID_HANDLE;
	SGD::HTexture Arrow = SGD::INVALID_HANDLE;

	IGameState* currState = nullptr;

	int zoneCounter = 0;

	//grapple detach handling
	SGD::HTexture slackGrapple = SGD::INVALID_HANDLE;
	float canGrapple = 0.0f;
	SGD::Vector grappleRenderVector;

	//death by corruption
	float corruptionTimer = 0.0f;

	//delay for grapple at start of game
	float grappleDelay = 0.01f;

#pragma region Acheivements
	int lightOrbsCollected = 0;
	int enemiesKilled = 0;
	int grapplesFired = 0;
	float acheivementTimer = 0;
	bool lightOrbAcheivement = false;
	bool enemyAcheivement = false;
	bool grappleAcheivement = false;
#pragma endregion
};
